<template>
  <div class="shopinfo-box">
    <div class="mui-card">
      <div class="mui-card-content">
        <div class="mui-card-content-inner">
          <swiper :imgData="imgData"></swiper>
        </div>
      </div>
    </div>

    <div class="mui-card">
      <div class="mui-card-header">{{goodsinfo.title}}</div>
      <div class="mui-card-content">
        <div class="mui-card-content-inner">
          <p class="price">
            市场价:<del>￥{{goodsinfo.market_price}}</del>&nbsp;&nbsp;
            销售价:<span class="now_price">${{goodsinfo.sell_price}}</span>
          </p>
          <p style="display:flex; height:30px;line-height:30px;">购买数量: <number></number> </p>
          <p>
            <mt-button type="primary" size="small">立即购买</mt-button>
            <mt-button type="danger" size="small">加入购物车</mt-button>
          </p>
        </div>
      </div>
    </div>

    <div class="mui-card">
      <div class="mui-card-header">商品参数</div>
      <!--内容区-->
      <div class="mui-card-content">
        <div class="mui-card-content-inner">
          <p>商品货号:{{goodsinfo.goods_no}}</p>
          <p>库存情况:{{goodsinfo.stock_quantity}}件</p>
          <p>上架时间:{{goodsinfo.add_time | dataF}}</p>
        </div>
      </div>
      <div class="mui-card-footer">
        <mt-button type="primary" size="large">图片介绍</mt-button>
        <mt-button type="danger" size="large">商品评论</mt-button>
      </div>
    </div>

  </div>
</template>
<script>
//导入轮播图
import swiper from '../subcom/swiper.vue';
//导入数字框
import number from '../subcom/infonum.vue';
export default {
  data() {
    return {
      id: this.$route.params.id,// 经路由参数对象中的id  挂载到 data, 方面后期调用
      imgData: [],//轮播图数据
      goodsinfo:{},//获取到的商品信息
    };
  },
  created() {
    this.getLunBo();
    this.getGoodsInfo
  },
  components: {
    swiper,
    number,
  },
  methods: {
    getLunBo() {
      this.$http.get("api/getthumimages/" + this.id)
      .then(res => {
        if (res.body.status === 0) {
          this.imgData = res.body.message;
        }
      });
    },
    getGoodsInfo() {
      this.$http.git("api/goods/getinfo/" + this.id)
      .then((res) => {
        if(res.body.status === 0) {
          this.goodsinfo = res.body.message[0]
        }
      })
    }
  }
};
</script>

<style lang="less" scoped>
.shopinfo-box {
  background: #eee;
  overflow: hidden;
  min-height: 500px;
  .now_price {
    color: red;
    font-size: 16px;
    font-weight: blod;
  }
  .mui-card-footer {
    display: block;
    button{
      margin: 15px 0;
    }
  }
}
</style>